/// @tags:
#include <cstdio>
#include <functional>
#include <iostream>
#include <numeric>
#include <queue>

using std::cin, std::cout, std::endl;

namespace BlueQuantum {

using ll = long long;

constexpr int maxn = 5e5 + 2;

struct Node {
  int val, pos;

  bool operator<(const Node &rhs) const {
    return val == rhs.val ? pos > rhs.pos : val < rhs.val;
  }

  // bool operator>(const Node &rhs) const { return !(*this < rhs); }
} a[maxn];

int win[maxn], ac[maxn];

int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    ll m;
    cin >> n >> m;
    win[n + 1] = n;
    for (int i = 1; i <= n; ++i) {
      cin >> a[i].val;
      ac[i] = a[i].val;
      win[i] = i;
      a[i].pos = i;
    }
    std::sort(a + 1, a + n + 1);
    std::priority_queue<Node> pq;
    int cnt = 0;

    for (int i = 1; i <= n; ++i) {
      if (m >= a[i].val) {
        m -= a[i].val;
        ++cnt;
        win[a[i].pos]--;
        pq.emplace(a[i]);
      } else {
        break;
      }
    }
    if (cnt == n) {
      cout << 1;
    } else {
      if (cnt == win[cnt + 1]) {
        cout << n - cnt;
      } else {
        if (!pq.empty() && m + pq.top().val >= ac[cnt + 1]) {
          cout << n - cnt;
        } else {
          cout << n - cnt + 1;
        }
      }
    }
    cout << '\n';
  }
  return 0;
}

}  // namespace BlueQuantum

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("/tmp/CodeTmp/testdata.in", "r", stdin);
  freopen("/tmp/CodeTmp/testdata.out", "w", stdout);
#else
  freopen("C. Yet Another Tournament.in", "r", stdin);
  freopen("C. Yet Another Tournament.out", "w", stdout);
#endif
#endif

  std::ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  return BlueQuantum::main();
}
